import 'package:banyou_app/app/routes/app_pages.dart';
import 'package:banyou_app/app/util/common_utils.dart';
import 'package:banyou_app/app/widget/caozuo_widget.dart';
import 'package:banyou_app/app/widget/mang_widget.dart';
import 'package:banyou_app/app/widget/you_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';

class UserinfoController extends GetxController {
  final info = {}.obs;
  final expectations = [].obs;
  final islahei = 0.obs;
  @override
  void onInit() {
    islahei.value = Get.arguments['islahei'] ?? 1;
    info.value = Get.arguments;

    expectations.value = info['Expectations'] ?? [];
    super.onInit();
  }

  //
  allDongtai() {
    Get.toNamed(Routes.MYDONGTAI, arguments: info.value);
  }

  jiechu() {
    MshowDialog('确定要解除拉黑吗？').then((value) {
      if (value == 1) {
        EasyLoading.show();
        Future.delayed(Duration(seconds: 1), () {
          EasyLoading.showToast('操作成功');
          info['islahei'] = 1;
          islahei.value = 1;
        });

        // Get.back();
      }
    });
  }

  clickCaozuo() {
    Get.bottomSheet(
      CaoZuoWidget(islahei.value == 2),
      isScrollControlled: true,
      backgroundColor: Colors.transparent,
    ).then((value) {
      if (value == 1) {
        print('object');
        MshowDialog('确定要拉黑吗？').then((value) {
          if (value == 1) {
            EasyLoading.show();
            Future.delayed(Duration(seconds: 1), () {
              EasyLoading.showToast('操作成功');
              info['islahei'] = 2;
              islahei.value = 2;
            });

            // Get.back();
          }
        });
      } else if (value == 2) {
        Get.toNamed(Routes.JUBAO);
      }
    });
  }

  yiqi() {
    String key = box.read("key") ?? "";
    if (key.isEmpty) {
      Get.offAllNamed(Routes.LOGIN);
    } else {
      Get.bottomSheet(
        YouWidget(),
        isScrollControlled: true,
        backgroundColor: Colors.transparent,
      );
    }
  }

  static showMang(String title) {
    Get.dialog(MangDialogView(title),
        barrierColor: Colors.black.withAlpha(100));
  }

  @override
  void onReady() {
    super.onReady();
  }

  @override
  void onClose() {}
}
